package com.cetc32.webutil.client.config;

import com.cetc32.webutil.client.bean.SSOProperties;
import com.cetc32.webutil.client.bean.URLPermissions;
import com.cetc32.webutil.client.interceptors.ServiceAuthInerceptors;
import com.cetc32.webutil.client.resolvers.LoginUserResolver;
import com.cetc32.webutil.common.util.HttpclientUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

@Configuration
public class ServiceMVCConfiguration extends WebMvcConfigurerAdapter {
    @Autowired
    ServiceAuthInerceptors authInterceptor;
    @Autowired
    LoginUserResolver loginUserResolver;


    @Override
    public void addInterceptors(InterceptorRegistry registry){
        registry.addInterceptor(authInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/error**")
                .excludePathPatterns("/static/**")
                .excludePathPatterns("/swagger-ui.html")
                .excludePathPatterns("/configuration/ui")
                .excludePathPatterns("/swagger-resources")
                .excludePathPatterns("/configuration/security")
                .excludePathPatterns("/v2/api-docs")
                .excludePathPatterns("/error")
                .excludePathPatterns("/webjars/**")
                .excludePathPatterns("/favicon.ico");
        super.addInterceptors(registry);
    }


    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(loginUserResolver);
    }
}